/*
	This file is part of AVRCppLib.

    AVRCppLib is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    AVRCppLib is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with AVRCppLib.  If not, see <http://www.gnu.org/licenses/>.

    Copyright (C) Maxime Lemonnier 2007-2011
 */
#ifndef CppExtensions_H_
#define CppExtensions_H_

#include <stddef.h>

namespace Allocators
{
	enum Allocator
	{
		MALLOC,
		CALLOC,
		STACK,
		EEPROM,
		FLASH
	};
}
__extension__ typedef int __guard __attribute__((mode (__DI__)));
extern "C" int __cxa_guard_acquire(__guard *);
extern "C" void __cxa_guard_release (__guard *);
extern "C" void __cxa_guard_abort (__guard *);
extern "C" void __cxa_pure_virtual(void);

#define FORCE_INLINE __attribute__((always_inline))

using Allocators::Allocator;

void* operator new(size_t size);

void* operator new(size_t size, void* memory); //realloc!

inline void* operator new(size_t size, Allocator allocator) __attribute__((always_inline));

void* operator new[](size_t size);

void* operator new[](size_t size, void* memory); //realoc!

inline void* operator new[](size_t size, Allocator allocator) __attribute__((always_inline));

void operator delete(void* memory);

void operator delete[](void* memory);

#include "CppExtensions-definitions.h"

#endif /* CPPEXTENSIONS_H_ */
